package com.tyrone.concurrent.basic;

import com.tyrone.concurrent.utils.SleepUtils;

/**
 * Daemon 。main 线程结束之后，不管你的Daemon线程是否执行完都会退出
 * @author xieyl
 * @create 2021/11/30 21:44
 */
public class Daemon {
    public static void main(String[] args) {
        Thread thread = new Thread(new DaemonRunner(),"DaemonRunner");
        thread.setDaemon(true);
        thread.start();
    }

    static class DaemonRunner implements Runnable{
        @Override
        public void run() {
            try {
                SleepUtils.second(10);
           }finally {
                //看看是否会执行
                System.out.println("DaemonThread finally Run");
            }
        }
    }
}
